package redis

import (
	"cloud-storage/global"
	"cloud-storage/lib"
	"context"
	"time"
)

// SetRedisJwt 将token存入缓存中
func SetRedisJwt(jwt, phone string) error {
	//过期时间
	times := lib.JWTSetting.ExpiresTime * time.Second
	err := global.Redis.Set(context.Background(), Tokens+phone, jwt, times).Err()
	return err
}

// GetRedisJwt 从缓存中取出token
func GetRedisJwt(phone string) (redisJwt string, err error) {
	redisJwt, err = global.Redis.Get(context.Background(), Tokens+phone).Result()
	return
}
